//
//  Account.m
//  记账本
//
//  Created by lirilu on 15/3/13.
//  Copyright (c) 2015年 glirlu@gmail.com. All rights reserved.
//

#import "Account.h"

@implementation Account

+ (NSString*)filePath{
    NSString *docPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)objectAtIndex:0];
    NSString *path = [docPath stringByAppendingPathComponent:@"Account.data"];
    return path;
}

+ (NSString*)filePath:(NSString*)name{
    NSString *docPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)objectAtIndex:0];
    NSString *path = [docPath stringByAppendingPathComponent:name];
    path = [path stringByAppendingString:@".data"];
    return path;
}


- (void)encodeWithCoder:(NSCoder *)aCoder {//将属性进行编码
    [aCoder encodeObject:[NSString stringWithFormat:@"%d",self.ID] forKey:@"ID"];
    [aCoder encodeObject:[NSString stringWithFormat:@"%f",self.Money] forKey:@"Money"];
    [aCoder encodeObject:[NSString stringWithFormat:@"%d",self.PayMode] forKey:@"PayMode"];
    [aCoder encodeObject:self.PayModeStr forKey:@"PayModeStr"];
    [aCoder encodeObject:self.Time forKey:@"Time"];
    [aCoder encodeObject:self.Dotime forKey:@"DoTime"];
    [aCoder encodeObject:self.Detail forKey:@"Detail"];
}

- (id)initWithCoder:(NSCoder *)aDecoder {//将属性进行解码
    self.ID = (int)[[aDecoder decodeObjectForKey:@"ID"] integerValue];
    self.Money =[[aDecoder decodeObjectForKey:@"Money"] floatValue];
    self.PayMode = (int)[[aDecoder decodeObjectForKey:@"PayMode"] integerValue];
    self.PayModeStr = [aDecoder decodeObjectForKey:@"PayModeStr"];
    self.Time = [aDecoder decodeObjectForKey:@"Time"];
    self.Dotime = [aDecoder decodeObjectForKey:@"DoTime"];
    self.Detail = [aDecoder decodeObjectForKey:@"Detail"];
    
    return self;
}
@end
